<?php
declare (strict_types = 1);

namespace app\common\service;
use think\App;
use think\Service;
use app\common\components\User;


class UserService  extends Service
{

    /**
     * 注册服务
     *
     * @return mixed
     */
    public function register()
    {
        return $this->app->bind('user', User::class);
    }


    /**
     * 创建user组建
     */
    public function boot()
    {
        User::setIdentityClass(config('service.user.identityClass'));
        User::setLoginUrl(request()->loginUrl());

        User::maker(function (User $user) {
            $user->encryptSlat  = config('service.user.encryptSlat');
            $user->enableAutoLogin  = config('service.user.enableAutoLogin');
            $user->autoRenewCookie  = config('service.user.autoRenewCookie');
            $user->authTimeout  = config('service.user.authTimeout');
            $user->absoluteAuthTimeout  = config('service.user.absoluteAuthTimeout');
        });
    }
}
